/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pehulja.mmdo.coursework.math.checkingResults;

import com.pehulja.mmdo.coursework.math.SimplexTable;
import com.pehulja.mmdo.coursework.math.Solver;
import com.pehulja.mmdo.coursework.math.matrix.Matrix;
import com.pehulja.mmdo.coursework.math.matrix.MatrixMathematics;
import com.pehulja.mmdo.coursework.math.matrix.NoSquareException;
import org.apache.commons.math.linear.RealMatrix;

/**
 *
 * @author pehulja
 */
public class OptimalityChecking {
    private Solver solver;
    private double dualTaskFunctionValue, directTaskFunctionValue; 
    public OptimalityChecking(Solver solver) {
        this.solver = solver;
    }
        
    public boolean checkOptimality(){
        double[] dualTaskEqVars = solver.getSolutionEquationsDualTask();
        //Check IT
        dualTaskFunctionValue = solver.getDualTask().getGoalFunction().countValue(solver.getSolutionEquationsDualTask());
        directTaskFunctionValue = solver.getFunctionOptimalValue();
        
        return Math.abs(dualTaskFunctionValue - directTaskFunctionValue)<Solver.Error;
    }
}
